package xyz.suancaiyu.userservice.utils;

import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;

/**
 * @author puruidong
 * @version 2019/1/21 23:39
 */
public class BPwdEncoderUtil {


    private static final BCryptPasswordEncoder encoder = new BCryptPasswordEncoder();

    /**
     * 用BCryptPasswordEncoder
     *
     * @param password
     * @return
     */
    public static String BCryptPassword(String password) {
        return encoder.encode(password);
    }

    /**
     * @param rawPassword
     * @param encodedPassword
     * @return
     */
    public static boolean matches(CharSequence rawPassword, String encodedPassword) {
        return encoder.matches(rawPassword, encodedPassword);
    }


}
